<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="com.jframe.sys.utils.StringUtil" %>
<%@page import="com.jframe.sso.model.CurUser"%>
<%@page import="com.jframe.sys.utils.CalendarUtil"%>
<%
int id = StringUtil.parseInt(request.getParameter("id"));
String contextPath = request.getContextPath();
CurUser user = (CurUser)session.getAttribute("curUser");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/inc/editInc.jsp" />
<script type="text/javascript" charset="utf-8" src="<%=contextPath %>/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<%=contextPath %>/js/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="<%=contextPath %>/js/ueditor/lang/zh-cn/zh-cn.js"></script>
<jsp:include page="/inc/basedwr.jsp" />
<script type="text/javascript">
var action = 'counselAction';
var contextPath = '<%=request.getContextPath()%>';

   
   $(document).ready(function(){
	   
	   var editor = new UE.ui.Editor({
			UEDITOR_HOME_URL:contextPath + '/js/ueditor/'
			,toolbars:[] 
			 ,wordCount:false        //是否开启字数统计
		    ,maximumWords:1000       //允许的最大字符
		    ,initialFrameHeight:170
		     ,autoHeightEnabled:false
		   }); 
		   editor.render("contentInfo");
		   
		var editor2 = new UE.ui.Editor({
			UEDITOR_HOME_URL:contextPath + '/js/ueditor/'
			,toolbars:[] 
			 ,wordCount:false        //是否开启字数统计
		    ,maximumWords:1000       //允许的最大字符
		    ,initialFrameHeight:170
		     ,autoHeightEnabled:false
		   }); 
		 editor2.render("question");
		   var saveForm = function(){
				var content = editor.getContentTxt();
				var question = editor2.getContentTxt();
				if(content==''||content==null){
					alertInfo("请输入回复内容");
					return;
				}
				var validate = $('#data').form('validate');
				if(validate){
				$.ajax({
					url:action+".do?method=save",
					data:{obj:$("#data").form2json(),content:content,question:question},
					dataType:'json',
					type:'post',
					success:function(data){
						if(data.result==true){
							$('#data').form('load',data.obj);
							alertInfo('保存成功！');
							parent.$('#grid').datagrid('reload');
						}
						else{
							alertError('保存失败！');
						}
					}
				});
				}else{
					return validate;
				}
			};
			$('#saveBtn').click(saveForm);
			
			$.ajax({
				url: action+'.do?method=getObjById',
				type: 'post',
				data:{id:$('#id').val()},
				dataType:'json',
			    success: function(data){
			    	$('#data').form('load',data);
			    	UE.getEditor('contentInfo').ready(function(){ 
			    		editor.setContent(data.content,false);//这里给编辑器添加内容 
		            });
			    	UE.getEditor('question').ready(function(){ 
			    		editor2.setContent(data.question,false);//这里给编辑器添加内容 
		            });
			    }
			});
			
   });

</script>
</head>
<body>
    <form id="data" method="post">
    	<input type="hidden" id="id" name="id" value="<%=id%>"/>
	    <table width="100%" class="tableForm">
	   		<tr align="center">
		    	<th colspan="4">		    
		    		<span>在线问答管理</span>
			    </th>
		    </tr>
		     <tr>
				<td align="right" width="20%">
		    		问题标题：
		    	</td>
				<td width="80%" colspan="3">
					<input type="text" id="questTitle" name="questTitle" required="true" style="width:610px;" class="easyui-validatebox"/>
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
		    		提问时间：
		    	</td>
				<td width="30%">
					<input type="text" id="askTime" name="askTime" required="true" style="width:120px;" class="easyui-datetimebox" />
				</td>
					<td align="right" width="20%">
		    		文件类别：
		    	</td>
				<td width="30%">
					<select id="typeId" name="typeId"  class="easyui-combotree" style="width:125px;" required="true" url="<%=request.getContextPath()%>/counselAction.do?method=getCombotree&key=sm_cms_counselType" ></select>
				</td>		
			</tr>
		    <tr>
				<td align="right" width="20%">
		    		问题内容：
		    	</td>
				<td width="80%" colspan="3">
				<div style="width: 610px;">
					<textarea id="question" name="question"></textarea>
				</div>
				</td>    
			</tr>
			 <tr>
			 	<td align="right" width="20%">
		    		回复：
		    	</td>
				<td width="80%" colspan="3">
				<div style="width: 610px;">
					<textarea id="contentInfo" name="contentInfo"></textarea>
				</div>
				</td>    	
			</tr>
			<tr>
				<td align="right" width="20%">
		    		是否常见：
		    	</td>
				<td width="30%">
					<select id="isConmmon" name="isConmmon" required="true" style="width:160px;" valueField="id" textField="text" class="easyui-combobox" url="<%=request.getContextPath()%>/counselAction.do?method=getCombobox&key=dm_cms_isConmmon"></select>&nbsp;&nbsp;&nbsp;&nbsp;
				</td>
				<td align="right" width="20%">回复状态：</td>
				<td width="30%"><select id="isReview" name="isReview" required="true" style="width:125px;" valueField="id" textField="text" class="easyui-combobox" url="<%=request.getContextPath()%>/counselAction.do?method=getCombobox&key=dm_cms_isReview"></select>&nbsp;&nbsp;&nbsp;&nbsp;</td>				
			</tr>
			<tr>
				<td align="right" width="20%">
		    		回复时间：
		    	</td>
				<td width="30%">
					<input type="text" id="reviewTime" name="reviewTime" required="true" style="width:120px;" class="easyui-validatebox" value="<%=CalendarUtil.getDateTime()%>"/>
				</td>
				<td align="right" width="20%">回复人：</td>
				<td width="30%"><input type="text" id="reviewUser" name="reviewUser" required="true" style="width:120px;" class="easyui-validatebox" value="<%=user.getUserName()%>"/></td>				
			</tr>
			<tr align="center">
				<td colspan="4">
					<a id='saveBtn' class="easyui-linkbutton" plain="true" iconCls="icon-save">保存</a>
				</td>
			</tr>
		</table>
    </form>
</body>
</html>